package com.minigame.rpc.network.command;

import com.minigame.rpc.network.command.msg.ServerInfoMsg;
import io.netty.buffer.ByteBuf;

public class ServerInfoCommand extends AbstractCommand<ServerInfoMsg>{

    @Override
    protected void encode(ByteBuf byteBuf, ServerInfoMsg serverInfoMsg) {
        encodeString(byteBuf,serverInfoMsg.getId());
        encodeString(byteBuf,serverInfoMsg.getServiceName());
    }

    @Override
    protected ServerInfoMsg decode(ByteBuf byteBuf) {
        ServerInfoMsg serverInfoMsg = new ServerInfoMsg();
        serverInfoMsg.setId(decodeString(byteBuf));
        serverInfoMsg.setServiceName(decodeString(byteBuf));
        return serverInfoMsg;
    }

    @Override
    protected int command() {
        return CommandConstant.SERVER_INFO;
    }
}
